package com.yqkj.zysoft.upms.controller;


import  com.project.easy.common.util.constants.SysModelConstant;
import  com.project.easy.common.util.constants.VersionConstant;
import  com.project.easy.common.util.dto.OneLongApiContextParam;
import  com.project.easy.common.util.dto.R;
import com.project.easy.common.framework.web.annotation.ApiValidator;
import com.project.easy.common.log.annotation.Logging;
import com.project.easy.common.framework.web.controller.BaseController;

import com.yqkj.zysoft.upms.entity.dto.DepartTreeResponse;
import com.yqkj.zysoft.upms.entity.dto.FrameWorkDepartAddRequest;
import com.yqkj.zysoft.upms.entity.dto.FrameWorkDepartUpdateRequest;
import com.yqkj.zysoft.upms.entity.dto.QueryDepartRequest;
import com.yqkj.zysoft.upms.service.IFrameworkDepartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 部门表 前端控制器
 * </p>
 *
 * @author GreatorMan.cool
 * @since 2022-09-13
 */
@RestController
@RequestMapping("/api/" + VersionConstant.ONE + "/upms/depart")
public class FrameworkDepartController extends BaseController {


    @Autowired
    private IFrameworkDepartService iFrameworkDepartService;
    /**
     * 新增
     * @param frameWorkDepartAddRequest 参数
     * @return 返回数据
     */
    @PostMapping("/add")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<Long> add(@RequestBody FrameWorkDepartAddRequest frameWorkDepartAddRequest) {
        return R.success(iFrameworkDepartService.add(frameWorkDepartAddRequest));
    }
    /**
     * 修改
     * @param frameWorkDepartUpdateRequest 参数
     * @return 返回数据
     */
    @PostMapping("/udpate")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<Boolean> udpate(@RequestBody FrameWorkDepartUpdateRequest frameWorkDepartUpdateRequest) {
        return R.success(iFrameworkDepartService.updateObject(frameWorkDepartUpdateRequest));
    }
    /**
     * 部门树
     * @param qeuryDepartRequest 参数
     * @return 返回数据
     */
    @PostMapping("/tree")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<List<DepartTreeResponse>> tree(@RequestBody QueryDepartRequest qeuryDepartRequest) {
        return R.success(iFrameworkDepartService.tree(qeuryDepartRequest));
    }
    /**
     * 删除
     * @param sysParamDto 参数
     * @return 返回数据
     */
    @PostMapping("/del")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<Boolean> del(@RequestBody OneLongApiContextParam sysParamDto) {
        return R.success(this.iFrameworkDepartService.del(sysParamDto.getKey()));
    }
    /**
     * 禁用
     * @param oneApiContextParam 参数
     * @return 返回数据
     */
    @PostMapping("/disAble")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<Boolean> disAble(@RequestBody OneLongApiContextParam oneApiContextParam) {
        return R.success(this.iFrameworkDepartService.disAble(oneApiContextParam.getKey()));
    }
    /**
     * 启用
     * @param oneApiContextParam 参数
     * @return 返回数据
     */
    @PostMapping("/able")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<Boolean> able(@RequestBody OneLongApiContextParam oneApiContextParam) {
        return R.success(this.iFrameworkDepartService.able(oneApiContextParam.getKey()));
    }
}
